﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisualPoint.Controls.Environments;
using VisualPoint.Controls.Models;

namespace VisualPoint.Controls.Actions
{
    public class WindowSelectAction : BaseAction
    {

        public override string Name
        {
            get 
            {
                return "Select Window";
            }
        }

        public override string Description
        {
            get 
            {
                if (SelectOption == WindowSelectOption.Standard)
                {
                    if (StandardWindowItemCollection.Dictionary.ContainsKey(WindowConstant))
                    {
                        return string.Format("Standard {0}", StandardWindowItemCollection.Dictionary[WindowConstant].Name);
                    }
                    return "Standard No Tool Selected";
                }
                else if (SelectOption == WindowSelectOption.ByName)
                {
                    return string.Format("{0}", WindowName);
                }
                return "";
            }
        }

        public override string Help
        {
            get 
            {
                return "Selects a Tool Window";
            }
        }

        public override BaseActionModel CreateModel()
        {
            return new WindowSelectActionModel() { Action = this };
        }


        private WindowSelectOption _SelectOption;
        public WindowSelectOption SelectOption
        {
            get
            {
                return _SelectOption;
            }
            set
            {
                if (_SelectOption != value)
                {
                    _SelectOption = value;
                    DoPropertyChanged("SelectOption");
                    DoDescriptionChanged();
                }
            }
        }

        private string _WindowName;
        public string WindowName
        {
            get
            {
                return _WindowName;
            }
            set
            {
                if (_WindowName != value)
                {
                    _WindowName = value;
                    DoPropertyChanged("WindowName");
                    DoDescriptionChanged();
                }
            }
        }

        private string _WindowConstant;
        public string WindowConstant
        {
            get
            {
                return _WindowConstant;
            }
            set
            {
                if (_WindowConstant != value)
                {
                    _WindowConstant = value;
                    DoPropertyChanged("WindowConstant");
                    DoDescriptionChanged();
                }
            }
        }

        public override void Run()
        {
            VisualPoint.Controls.Environments.Environment.Current.SelectWindow(SelectOption, WindowName, WindowConstant);
        }

        public override void InitializeNew()
        {
            WindowConstant = DteConstants.vsWindowKindSolutionExplorer;
        }
    }
}
